package zhihui.mobile.ui.shop.address;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.RelativeLayout;
import android.widget.TextView;

import zhihui.mobile.R;


/**
 * Created by 张公铭 on 2017/8/16 0016.
 */

public class ShopAddressSelectItemAdapter extends BaseAdapter
{
    private Context mContext;
    private LayoutInflater inflater;

    public ShopAddressSelectItemAdapter(Context context)
    {
        mContext = context;
        inflater = LayoutInflater.from(mContext);
    }

    @Override
    public int getCount()
    {
        return 0;
    }

    @Override
    public Object getItem(int position)
    {
        return null;
    }

    @Override
    public long getItemId(int position)
    {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent)
    {
        TextView tv_name, tv_phone, tv_address;
        CheckBox cb_select;

        if (convertView == null)
        {
            convertView = inflater.inflate(R.layout.shop_address_select_item, parent);
            tv_name = (TextView) convertView.findViewById(R.id.tv_shop_address_select_item_name);
            tv_phone = (TextView) convertView.findViewById(R.id.tv_shop_address_select_item_phone);
            tv_address = (TextView) convertView.findViewById(R.id.tv_shop_address_select_item_address);
            cb_select = (CheckBox) convertView.findViewById(R.id.cb_shop_address_select_item_select);

            ShopAddressSelectItemAdapter.ViewCache viewCache = new ShopAddressSelectItemAdapter.ViewCache();
            viewCache.tv_name = tv_name;
            viewCache.tv_phone = tv_phone;
            viewCache.tv_address = tv_address;
            viewCache.cb_select = cb_select;


            convertView.setTag(viewCache);
        } else
        {
            ShopAddressSelectItemAdapter.ViewCache viewCache = (ShopAddressSelectItemAdapter.ViewCache) convertView.getTag();
            tv_name = viewCache.tv_name;
            tv_phone = viewCache.tv_phone;
            tv_address = viewCache.tv_address;
            cb_select = viewCache.cb_select;
        }

        return convertView;
    }

    public class ViewCache
    {
        public TextView tv_name, tv_phone, tv_address;
        public CheckBox cb_select;
    }
}
